package com.leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No118
 * @description
 * @date 2021/2/5 下午4:02
 */
public class No118 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        List<List<Integer>> res = generate(num);
        print(res);

    }

    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> res = new ArrayList<>();
        if(numRows < 0){
            return res;
        }
        for (int i = 0; i < numRows ; i++) {
            List<Integer> subList = new ArrayList<>();

            for (int j = 0; j <= i ; j++) {
                // 第一个和最后一个
                if(j == 0 || j == i){
                    subList.add(1);
                }else{
                    subList.add(res.get(i - 1).get(j - 1) + res.get(i - 1).get(j));
                }
            }
            res.add(subList);
        }
        return res;

    }

    public static void print(List<List<Integer>> res){
        int len = res.size();
        for (int i = 0; i < len; i++) {
            List<Integer> list = res.get(i);
            int subLen = list.size();
            for (int j = 0; j < subLen; j++) {
                System.out.print(list.get(j));
                System.out.print(" ");
            }
            System.out.println();
        }
    }

}
